package org.cobaya.commons;

public abstract class Assert {

	public static void notBlank(String value, String message) {
		if (value == null || value.trim().length() == 0) {
			throw new IllegalArgumentException(message);
		}
	}

	public static void isStartsWith(String value, String prefix, String message) {
		notBlank(value, "value must not be null");
		notBlank(prefix, "prefix must not be null");
		if (!value.startsWith(prefix)) {
			throw new IllegalArgumentException(message);
		}
	}

	public static void isEndsWith(String value, String suffix, String message) {
		notBlank(value, "value must not be null");
		notBlank(suffix, "suffix must not be null");
		if (!value.endsWith(suffix)) {
			throw new IllegalArgumentException(message);
		}
	}

	public static void notNull(Object value, String message) {
		if (value == null) {
			throw new IllegalArgumentException(message);
		}
	}
}